<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" />
    <title>奖励惩罚</title>
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/weui.min.css')}}">
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/jquery-weui.css')}}">
    <link rel="stylesheet" href="/css/system/front-iconfont.css?v=2018121301">
    @if($skinid == 3)
        <link rel="stylesheet" href="/css/system/common.css?v={{time()}}">
        <link rel="stylesheet" href="/css/system/up-rewards.css?v={{time()}}">
    @elseif($skinid == 1)
        <link rel="stylesheet" href="/css/theme-blue/system/common.css?v={{time()}}">
        <link rel="stylesheet" href="/css/theme-blue/system/up-rewards.css?v={{time()}}">
    @elseif($skinid == 2)
        <link rel="stylesheet" href="/css/theme-pink/system/iconfont-pink.css">
        <link rel="stylesheet" href="/css/theme-pink/system/common.css?v={{time()}}">
        <link rel="stylesheet" href="/css/theme-pink/system/up-rewards.css?v={{time()}}">
    @endif
</head>
<body ontouchstart>
<div class="award-pub">
    {{--头部--}}
    <div class="award-top">
        <a class="award-top-lecon sure-btn active" href="javascript:;">
            <div class="award-top-left"></div>
            <span>审核</span>
            @if($count > 0)
            <span style="color: red">({{$count}})</span>
            @endif
        </a>
        <div>
            奖励惩罚
        </div>
        <div class="award-top-lecon">
            <div class="add-tip"></div>
            <span class="award-do">发起</span>
        </div>
    </div>
    <div class="min-con">
        {{--tabbar--}}
        <div class="header-top">
            <div class="weui-flex">
                <div class="weui-flex__item pull pull-up @if($id == 0) active @endif" onclick="window.location.href='{{url('/user/reward/reward')}}'">
                    <p class="">
                        奖励
                    </p>
                </div>
                <div class="weui-flex__item pull pull-up2 @if($id == 1) active @endif" style="margin-left: 2px;" onclick="window.location.href='{{url('/user/reward/reward?id=1')}}'">
                    <p class="">
                        惩罚
                    </p>
                </div>
                <div class="weui-flex__item pull pull-up3" style="margin-left: 2px;" onclick="window.location.href='{{url('/user/reward/shenpi')}}'">
                    <p class="">
                        待办事项
                    </p>
                </div>
            </div>
            {{--<div class="weui-search-bar" id="searchBar">--}}
              {{--<form class="weui-search-bar__form">--}}
                {{--<div class="weui-search-bar__box">--}}
                  {{--<i class="weui-icon-search"></i>--}}
                  {{--<input type="search" class="weui-search-bar__input" id="searchInput" placeholder="搜索" required="">--}}
                  {{--<a href="javascript:" class="weui-icon-clear" id="searchClear"></a>--}}
                {{--</div>--}}
                {{--<label class="weui-search-bar__label" id="searchText">--}}
                  {{--<i class="weui-icon-search"></i>--}}
                  {{--<span>搜索</span>--}}
                {{--</label>--}}
              {{--</form>--}}
              {{--<a href="javascript:" class="weui-search-bar__cancel-btn" id="searchCancel">取消</a>--}}
            {{--</div>--}}
            {{--@if($skinid == 2)--}}
                {{--<img class="add-tip" src="/img-theme-pink/add.png">--}}
            {{--@elseif($skinid == 1)--}}
                {{--<img class="add-tip" src="/img-theme-blue/add.png">--}}
            {{--@elseif($skinid == 3)--}}
                {{--<img class="add-tip" src="/img/add.png">--}}
            {{--@endif--}}
            {{--<i class="add-tip icon iconfont icon-hao"></i>--}}
            {{--@if($user->is_leader == 1)--}}
                {{--<div class="weui-flex flex-search">--}}
                    {{--<div class="weui-flex__item" style="text-align: center">--}}

                        {{--</a>--}}
                    {{--</div>--}}
                {{--</div>--}}
            {{--@endif--}}
        </div>
        <ul>
            @foreach($relate as $re)
                    <li>
                        <img class="pull-left" @if($re->kind==1) src="/img/reward{{$skinid}}.png" @else src="{{asset('/img/punish.png')}}" @endif>
                        <a href="javascript:void(0)">
                            <div class="sec-block">
                                <div class="up">
                                    <h3>@if($re->kind==1)提出奖励@else提出惩罚@endif<p class="p-time">{{$re->created_at->format('Ymd')}}</p></h3>
                                </div>
                                <div class="down">
                                    <p class="title-p">{{getUserName($re->from_user_id)}}发出一条对{{getUserName($re->to_user_id)}}的@if($re->kind==1)奖励@else惩罚@endif</p>
                                    <p>@if($re->kind==1)奖励@else惩罚@endif级别：{{$re->grade}}</p>
                                    @if($re->is_effective == 1)
                                        <i class="pass icon iconfont icon-queren"></i>
                                    @elseif($re->is_effective == 2)
                                        <i class="error icon iconfont icon-chahao"></i>
                                    @else
                                        <i class="wait icon iconfont icon-bolangnengguancedian"></i>
                                    @endif

                                </div>
                            </div>
                        </a>
                        <ul class="hidden">
                            @foreach($re->log as $k=>$v)
                                @if($k%2 == 0)
                                    <li class="clearfloat">
                                        <div class="right-div">
                                            <span class="circle-sp"></span>
                                            <p>{!! $v->des !!}</p>
                                        </div>
                                    </li>
                                @else
                                    <li class="clearfloat">
                                        <div class="left-div">
                                            <p>{!! $v->des !!}</p>
                                            <span class="circle-sp"></span>
                                        </div>
                                    </li>
                                @endif
                            @endforeach
                        </ul>
                    </li>
            @endforeach
            {{--<li>
                <img class="pull-left" src="{{asset('/img/punish.png')}}">
                <a href="javascript:void(0)">
                    <div class="sec-block">
                        <div class="up">
                            <h3>提出惩罚<p class="p-time">20181130</p></h3>
                        </div>
                        <div class="down">
                            <p class="title-p"> 你发出一条对张磊的惩罚</p>
                            <p>惩罚级别：高级</p>
                            <i class="pass icon iconfont icon-queren"></i>   
                        </div>
                    </div>
                </a>
                <ul class="hidden">
                    <li>
                        <span class="circle-sp"></span>
                        <p>提出惩罚申请<span class="time-span">2018-04-18 17:25</span></p>
                    </li>
                    <li>
                        <p>组长1审核通过<span class="time-span">2018-04-18 17:25</span></p>
                        <span class="circle-sp"></span>
                    </li>
                    <li>
                        <span class="circle-sp"></span><p>组长2审核通过<span class="time-span">2018-04-18 17:25</span></p>
                    </li>
                    <li>
                        <p>组长3审核通过<span class="time-span">2018-04-18 17:25</span></p><span class="circle-sp"></span>
                    </li>
                    <li>
                        <span class="circle-sp"></span><p>惩罚通过<span class="time-span">2018-04-18 17:25</span></p>
                    </li>
                </ul>
            </li>
            <li>
                <img class="pull-left" src="{{asset('/img/reward.png')}}">
                <a href="javascript:void(0)">
                    <div class="sec-block">
                        <div class="up">
                            <h3>提出奖励<p class="p-time">20181130</p></h3>
                        </div>
                        <div class="down">
                            <p class="title-p">
                                    你发出一条对陈冲的奖励
                            </p>
                            <p>奖励级别：中级</p>
                             <i class="wait icon iconfont icon-bolangnengguancedian"></i>                          
                        </div>
                    </div>
                </a>
                <ul class="hidden">
                    <li>
                        <span class="circle-sp"></span><p>kk<span class="time-span">2018-04-18 17:25</span></p>
                    </li>
                    <li>
                        <p>kk<span class="time-span">2018-04-18 17:25</span></p><span class="circle-sp"></span>
                    </li>
                </ul>
            </li>
            <li>
                <img class="pull-left" src="{{asset('/img/reward.png')}}">
                <a href="javascript:void(0)">
                    <div class="sec-block">
                        <div class="up">
                            <h3>提出奖励<p class="p-time">20181130</p></h3>
                        </div>
                        <div class="down">
                            <p class="title-p">
                                    你发出一条对陈冲的奖励
                            </p>
                            <p>奖励级别：中级</p>
                             <i class="error icon iconfont icon-chahao"></i>
                        </div>
                    </div>
                </a>
                <ul class="hidden">
                    <li>
                        <span class="circle-sp"></span><p>kk<span class="time-span">2018-04-18 17:25</span></p>
                    </li>
                    <li>
                        <p>kk<span class="time-span">2018-04-18 17:25</span></p><span class="circle-sp"></span>
                    </li>
                </ul>
            </li>--}}
        </ul>
    </div>
</div>
<div class="shadow-hidden"></div>
<div class="award-hidden">
    <div class="popup"><h3>提出奖励/惩罚</h3><i class="weui-icon-cancel"></i></div>
    <form onsubmit="return false;">
        <a class="award-link kaohe_rp" data-id="1" href="javascript:void(0)">
            <i class="icon iconfont icon-jiangzhang"></i>奖励
        </a>
        <input type="hidden" name="award" value="">
        <a class="pubnish-link kaohe_rp" data-id="2" href="javascript:void(0)">
            <i class="icon iconfont icon-jinggao"></i>惩罚
        </a>
        <input type="hidden" name="pubnish" value="">
        <select class="" name="tuid">
            @foreach($users as $u)
                <option value="{{$u->id}}">{{$u->qw_name}}</option>
            @endforeach
        </select>
        <select class="" name="class">
            <option value="高级">高级</option>
            <option value="中级">中级</option>
            <option value="低级">低级</option>
        </select>

        <textarea name="reason"></textarea>
        <button class="sub-mit kh_submit">提交</button>
        {!! csrf_field() !!}
    </form>
</div>
<div class="detail-pub">
</div>
<div class="fix-message">
    @if($skinid == 3)
        <img src="/img-theme-pink/que-3.png">
    @elseif($skinid == 1)
        <img src="/img-theme-pink/que-2.png">
    @elseif($skinid == 2)
        <img src="/img-theme-pink/que-1.png">
    @endif
</div>
<input type="hidden" name="idvalue" value="{{$id}}">
 @include('frontuser.caidan')

<script src="{{asset('/kaohe/js/jquery-2.1.4.min.js')}}"></script>
<script src="{{asset('/addons/jquery-weui-build/js/fastclick.js')}}"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>
<script src="{{asset('/addons/jquery-weui-build/js/jquery-weui.min.js')}}"></script>
<script>
    $(document).ready(function () {
        var token = $('input[name=_token]').val();
        $('.fix-message img').click(function () {
            $.alert("奖惩板块全员皆可参与，发起对他人的奖惩申请，并填写奖惩的理由，发起后奖励信息全员可见，惩罚信息只有关联人员可见，再进行逐层审批，直至生效；奖惩管理员可以审核公司的奖惩申请，并可查看公司所有正在发起或已经生效的奖惩记录详情。", "提示");
        })
        $('.kaohe-item').click(function(){
            $('.front-show-hidden').toggle();
        })
        $('.set-btn').click(function () {
            $('.set-hidden').toggle();
        })
        $('.add-tip').click(function () {
            $('.award-hidden').css('display','block');
            $('.shadow-hidden').css('display','block');
        })
        $('.award-hidden .popup i').click(function () {
            $('.award-hidden').css('display','none');
            $('.shadow-hidden').css('display','none');
        })
        $('.award-hidden .sub-mit').click(function () {
            $('.award-hidden').css('display','none');
            $('.shadow-hidden').css('display','none');
        })
        $('.award-hidden form a').each(function () {
            $(this).click(function () {
                $(this).siblings().removeClass('active')
                $(this).addClass('active');

            })
        })
        $('.min-con li a').click(function () {
                $('.detail-pub').css('display','block');
            $('.shadow-hidden').css('display','block');
            console.log($(this).find('.title-p').text());
            console.log($(this).next().html());
                $('.detail-pub').html('<div class="popup">'+
                                      '<h3>详情</h3>'
                                      +'<i class="weui-icon-cancel"></i>'
                                      +'</div>'
                                      +'<p>'+$(this).find('.title-p').text()+'</p>'+'<ul>'+$(this).next().html()+'</ul>');
                $('.detail-pub .popup i').click(function () {
                    $('.detail-pub').css('display','none');
                    $('.shadow-hidden').css('display','none');
                })
                if(($(this).next().find('li').length)%2==0){
                    console.log(1)
                    $('.detail-pub ul li:last-child .circle-sp').css('background-image','url({{asset('/img/last-2.png')}})');
                }else if(($(this).next().find('li').length)%2==1){
                    $('.detail-pub ul li:last-child .circle-sp').css('background-image','url({{asset('/img/last.png')}})');
                    console.log(2)
                }
        });

        $('.kh_submit').click(function(){
            console.log(1111)
            var toke = $('input[name=_token]').val();
            var cid = $('.kaohe_rp.active').attr('data-id');//奖励或惩罚
            var uid = $('select[name=tuid]').val();
            var reason= $('textarea[name=reason]').val();
            var clas = $('select[name=class]').val();
            if(cid != 1 && cid != 2){
                $.toast("请选择奖励或惩罚", "text");
            }else{
                $.ajax({
                    'url': '/user/reward/add-reward?_token='+toke+'&uid='+uid+'&kind='+cid,
                    'type': 'POST',
                    'data': {'reason':reason,'grade':clas},
                    error: function (request) {
                        console.log("error");
                    },
                    success: function (data) {
                        if (data.status == 'success') {
                            $.toast("操作成功");
                            setTimeout(function(){ window.location.reload(); }, 1000);
                        } else {
                            $.toast(data.msg, 'forbidden');
                        }
                    },
                });
            }
        });

    });

    $('.no-access').click(function(){
        $.toast("您不是组长，无权查看", "text");
    });

    $(document).on('click','.award-top-lecon.sure-btn',function(){
        var toke = $('input[name=_token]').val();
        $.ajax({
            type: 'post',
            url: "/user/reward/check-verify-list?" +"_token="+toke,
            data: '',
            dataType: 'json',
            success: function (data) {
                if (data.status == 'success') {
                    window.location.href='/user/reward/verify-list';
                } else {
                    $.toast(data.msg,'forbidden');
                }
            },
            error: function () {
                $.toptip('网络异常请重试','warning');
            }
        });
    });

//    头部奖励、惩罚、待办事项tabbar
    $('.pull').click(function () {
        $(this).addClass('active');
        $(this).siblings().removeClass('active');
    })



</script>
</body>
</html>